fontawesome package 您所在的位置:网站首页 r markdown how to insert page fontawesome package

fontawesome package

2023-04-20 09:39| 来源: 网络整理| 查看: 265

The fontawesome R package makes it very easy to insert Font Awesome icons into R Markdown documents and Shiny apps (or, anywhere else you need to put them).

Examples

The fa() function can be used to insert an FA icon. For example, we can get the r-project icon in steelblue:

fa(name = "r-project", fill = "steelblue") #>

As can be seen, what we really get from the function is an SVG object that represents the icon. This can be directly used within R Markdown with:

{text} `r fa(...)` {text}

Font Awesome SVG icons are great to use instead of tags + font files for a few reasons:

There is less overhead in a Shiny app or R Markdown document since an tag requires computation to obtain the icon ( tags represent the actual icon)Using tags has a 'being online' requirement since network activity is necessary for resolving these tags (SVGs in fontawesome are stored in the package, so, no Internet connectivity is necessary for that)There are styling options available for SVG that aren't there for icon fontsR Markdown

Here is an example R Markdown document that includes Font Awesome icons:

--- title: "Font Awesome in R Markdown" output: html_document --- ```{r load_packages, message=FALSE, warning=FALSE, include=FALSE} library(fontawesome) ``` # Just a few tests with `r fa("font-awesome-logo-full", fill = "forestgreen")` It works well in headings... # `r fa("r-project", fill = "steelblue")` H1 Heading ## `r fa("r-project", fill = "steelblue")` H2 Heading ### `r fa("r-project", fill = "steelblue")` H3 Heading #### `r fa("r-project", fill = "steelblue")` H4 Heading ##### `r fa("r-project", fill = "steelblue")` H5 Heading ...and works equally well within inline text: `r fa("r-project", fill = "steelblue")`.

This will appear, when knit, as:

Shiny

Here鈥檚 a Shiny app (from the Shiny Gallery) that鈥檚 been slightly modified to incorporate Font Awesome icons in the text above the three search fields:

library(shiny) library(DT) library(ggplot2) library(fontawesome) ui


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有